<?php get_header(); 

// To Show Banner and Title
get_template_part( 'inc/title-bar' ); 
?>


<!--OPENING CONTENT-->
<div id="content">
        
        <?php 
		// Include Breadcrumb Bar
		get_template_part( 'inc/breadcrumb-sharebar' ); 
		 ?>
      	
        <!-- OPENING POST WRAPPER -->
        <div class="post-wrapper">
        		
				<?php 
				if ( have_posts() ) : 
				while ( have_posts() ) : 
					the_post(); 
										
				?>
                
                <div class="property-info-block clearfix">
                        
						<?php
						$property_images = get_post_meta($post->ID, 'locality_property_pictures');
						$images_count = count($property_images);
						if ( $images_count > 0 || has_post_thumbnail() )
						{
						?>
                        <!--OPENING PROPERTY GELLARY -->
                        <div class="property-slider-wrapper clearfix">                                                                                                                                                               
                                <div id="slideshow">
									<?php   
									if( $images_count > 0 )  
									{                           																								
										foreach($property_images as $image)
										{
											echo wp_get_attachment_image($image, 'property-gallery', false, array( 'class' => 'property-gallery' ));
										}
									}
									else
									{
										the_post_thumbnail('property-gallery', array( 'class'	=> 'property-gallery' ));
									}
									?>
                                </div>                                
                        </div><!--CLOSING PROPERTY GELLARY --> 
                       	<?php
						}
						
						?>
                        <!--OPENING PROPERTY INFO -->
                        <div class="property-info">
                                <h3 class="property-single-title"><?php the_title(); ?></h3>
								<?php
								$property_date = get_post_meta($post->ID, 'locality_date', true);
								if(!empty($property_date))
								{
									?>
	                                <span class="date"><?php echo $property_date; ?></span>
									<?php
								}
								?>
                                
								<ul class="property-features-block">
										<?php
										$locality_property_size = get_post_meta($post->ID, 'locality_property_size', true);
										if(!empty($locality_property_size))
										{
											?>
											<li class="home-size"><?php echo $locality_property_size; theme_unit(); ?></li>
											<?php
										}

										$locality_property_bedrooms = get_post_meta($post->ID, 'locality_property_bedrooms', true);
										if(!empty($locality_property_bedrooms))
										{
											?>
											<li class="home-beds"><?php echo $locality_property_bedrooms; ?> <?php _e('Beds','locality'); ?></li>
											<?php
										}

										$locality_garage = get_post_meta($post->ID, 'locality_garage', true);
										if(!empty($locality_garage))
										{
											?>
											<li class="home-garage"><?php echo $locality_garage; ?> <?php _e('Garage','locality'); ?></li>
											<?php
										}

										$locality_property_bathrooms = get_post_meta($post->ID, 'locality_property_bathrooms', true);
										if(!empty($locality_property_bathrooms))
										{
											?>
											<li class="home-baths"><?php echo $locality_property_bathrooms; ?> <?php _e('Baths','locality'); ?></li>
											<?php
										}

										$locality_furnish = get_post_meta($post->ID, 'locality_furnish', true);
										if(!empty($locality_furnish))
										{
											?>
											<li class="furnished"><?php echo $locality_furnish; ?></li>
											<?php
										}

										$locality_mortgage = get_post_meta($post->ID, 'locality_mortgage', true);
										if(!empty($locality_mortgage))
										{
											?>
											<li class="mortgage"><?php echo $locality_mortgage; ?></li>
											<?php
										}
										?>										
                                </ul> 
								
								<div class="single-pricetag">
										<?php 
										$terms = get_the_terms( $post->ID,"property-type" );
										
										if ( $terms && ! is_wp_error( $terms ) ) 
										{														   														   
											   foreach ( $terms as $term )
											   {															   
													echo '<small><a class="property-type" href="' . get_term_link($term->slug, "property-type" ) .'">'.$term->name.'</a></small>';
													break; // to display only one property type
											   }														   													   														   
										}
													
										?>
										<h5 class="price"><?php theme_currency(); echo number_format(intval(get_post_meta($post->ID, 'locality_property_price', true))); ?></h5>
								</div>
                        </div><!--CLOSING PROPERTY INFO -->
                        
						 <div id="nav"></div>
						 
                </div>
                
				<div class="post-data">
                	<?php the_content(); ?>
                </div>
				                
				<?php 
												
				$terms = get_the_terms( $post->ID, 'property-feature' );
				
				if ( $terms && !is_wp_error( $terms ) )
				{	
					?>
					<!--OPENING FEATURED BLOCK -->
					<div class="propter-freature-list clearfix">
						<h3 class="title"><?php _e('Features','locality'); ?></h3>
						<ul>
							<?php	
							foreach($terms as $term)
							{
								?>																
								<li>
									<a href="<?php echo get_term_link($term->slug, 'property-feature'); ?>"><?php echo $term->name; ?></a>
								</li>												
								<?php 
							}
							?>
						</ul>
					</div>
					<?php
			   }
					?>                        
                
                <!--OPENING VIRTUAL TUOR VIDEO -->
                
                <?php
						$youtube_id = get_post_meta($post->ID, 'locality_youtube_link', true);	
														 
						if(!empty($youtube_id))
						{
							    ?>
								<div class="virtual-tour-block">
	                        		<h3 class="title"><?php _e('Virtual Tour','locality'); ?></h3>
			                        <div class="virtual-video">			                        		
											<object width="300" height="206">
											<param name="movie" value="http://www.youtube.com/v/<?php echo $youtube_id; ?>?version=3&amp;hl=en_GB&amp;rel=0"></param>
											<param name="allowFullScreen" value="true"></param>
											<param name="allowscriptaccess" value="always"></param>
											<embed src="http://www.youtube.com/v/<?php echo $youtube_id; ?>?version=3&amp;hl=en_GB&amp;rel=0" type="application/x-shockwave-flash" width="300" height="206" allowscriptaccess="always" allowfullscreen="true"></embed>
											</object>
			                        </div>
								</div><!--CLOSING VIRTUAL TUOR VIDEO -->
		                        <?php
						}
				?>
                                
                <hr />
                
                <!--GOOGLE MAP -->
                 <?php
					$location_map = get_post_meta($post->ID, 'locality_property_location', true);	
													 
					if(!empty($location_map))
					{
						?>
		                <div class="map-container clearfix">
								<?php 
								$a  = $location_map;
								$w = 636;
								$h = 340;
								$z = 15;
								$i = 'near';
								$iframe_tag = 'iframe';
								echo '<'.$iframe_tag.' width="'.$w.'" height="'.$h.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q='.$a.'&amp;ie=UTF8&amp;hq=&amp;hnear='.$a.'&amp;z='.$z.'&amp;output=embed&amp;iwloc='.$i.'"></'.$iframe_tag.'>
									  <small><a class="map-zoom-button" href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q='.$a.'&amp;ie=UTF8&amp;hq=&amp;hnear='.$a.'&amp;z='.$z.'&amp;iwloc='.$i.'" class="enlarge">Enlarge</a></small>'; ?>
		                </div><!--CLOSING GOOGLE MAP -->
		                <?php
					} 
				?>				
																						
						<div class="agent-info-box">		
							
							<h5 class="title"><?php _e('Agent Info:','locality'); ?></h5>
																
							<div class="agent-data clearfix">
							
								<a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>">
									<?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), '70' ); }?>
								</a>																							
								<div class="agent-content-container clearfix">
										<h3><?php the_author_posts_link() ?></h3>
										
										<div class="agent-contact">
											<?php
											$mobile = get_the_author_meta( 'mobile' );
											$office = get_the_author_meta( 'office' );
											$fax = get_the_author_meta( 'fax' );
											
											if(!empty($mobile))
											{
												?>
											  	<span class="mobile"><strong><?php _e('Mobile','locality'); ?></strong>: <?php echo $mobile;?></span>
												<?php
											}
											
											if(!empty($office))
											{
												?>
												<span class="office"><strong><?php _e('Office','locality'); ?></strong>: <?php echo $office;?></span>
												<?php
											}
											
											if(!empty($fax))
											{
												?>
												<span class="fax"><strong><?php _e('Fax','locality'); ?></strong>: <?php echo $fax;?></span>
												<?php
											}					
											?>
										</div>
										
										<div class="agent-desc">
											<p><?php the_author_meta('description'); ?></p>
										</div>
								</div>
								
							</div>
						</div>
				<?php	
					endwhile;		
					endif;
					comments_template(); 
				?>
                
        </div><!-- CLOSING POST WRAPPER -->
        
</div><!-- CLOSING CONTENT--> 

<!-- SIDEBAR -->
<?php get_sidebar('blog'); ?>

<!-- FOOTER -->
<?php get_footer(); ?>